package com.example.springboot.oauth2.jpa;

import com.example.springboot.oauth2.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface UserJPA extends JpaRepository<User, String> {

    @Query("SELECT u FROM User u WHERE LOWER(u.username) = LOWER(:username)")
    User findByUsernameCaseInsensitive(@Param("username") String username);

    @Query("SELECT u FROM User u WHERE LOWER(u.email) = LOWER(:email)")
    User findByEmailCaseInsensitive(@Param("email") String email);

    @Query("SELECT u FROM User u WHERE LOWER(u.phone) = LOWER(:phone)")
    User findByPhone(@Param("phone") String phone);

}